From b67e36df49f067cbd5ba899f9fbcc755f38d4b4f Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 4 Sep 2025 08:31:31 +0000 Subject: (대표님, 최겸, 임수민) 작업사항 커밋 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[lng]/admin/edp-progress/page.tsx | 488 +++++++--------------------------- 1 file changed, 96 insertions(+), 392 deletions(-) (limited to 'app/[lng]/admin/edp-progress/page.tsx') diff --git a/app/[lng]/admin/edp-progress/page.tsx b/app/[lng]/admin/edp-progress/page.tsx index 4efb739c..c42a1db7 100644 --- a/app/[lng]/admin/edp-progress/page.tsx +++ b/app/[lng]/admin/edp-progress/page.tsx @@ -2,430 +2,134 @@ import React from 'react'; import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; -import { Input } from '@/components/ui/input'; -import { Label } from '@/components/ui/label'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; -import { Separator } from '@/components/ui/separator'; import { ScrollArea } from '@/components/ui/scroll-area'; -import { - calculateVendorFormCompletion, - getProjectVendorCompletionSummary, - calculateVendorContractCompletion, - getVendorAllContractsCompletionSummary, - getAllVendorsContractsCompletionSummary, - getAllProjectsVendorCompletionSummary, - type VendorFormCompletionStats, - type ProjectVendorCompletionSummary, - type VendorAllContractsCompletionSummary -} from '@/lib/forms/vendor-completion-stats'; -import { Loader, TestTube, BarChart, FileText, TrendingUp } from 'lucide-react'; +import { getAllVendorsContractsCompletionSummary } from '@/lib/forms/vendor-completion-stats'; +import { Loader, Users, RefreshCw } from 'lucide-react'; import { toast } from 'sonner'; -interface TestResult { - type: string; - data: VendorFormCompletionStats | ProjectVendorCompletionSummary | VendorAllContractsCompletionSummary | unknown; +interface VendorProgress { + vendorId: number; + vendorName: string; + totalForms: number; + tagCount: number; + totalRequiredFields: number; + totalFilledFields: number; + completionPercentage: number; } export default function EDPProgressTestPage() { - const [loading, setLoading] = React.useState(null); - const [results, setResults] = React.useState(null); - - // Form inputs - const [contractItemId, setContractItemId] = React.useState('123'); - const [formCode, setFormCode] = React.useState('SPR_LST'); - const [projectId, setProjectId] = React.useState('1'); - const [vendorId, setVendorId] = React.useState('1'); + const [loading, setLoading] = React.useState(false); + const [vendorProgress, setVendorProgress] = React.useState([]); - const handleTest = async (testType: string, testFunction: () => Promise) => { - setLoading(testType); - setResults(null); + const loadVendorProgress = async () => { + setLoading(true); try { - const result = await testFunction(); - setResults({ type: testType, data: result }); + const result = await getAllVendorsContractsCompletionSummary(); - if (result) { - toast.success(`${testType} 테스트 완료`); + if (result && result.vendors) { + const progressData: VendorProgress[] = result.vendors.map(vendor => ({ + vendorId: vendor.vendorId, + vendorName: vendor.vendorName, + totalForms: vendor.totalForms, + tagCount: vendor.totalTags, + totalRequiredFields: vendor.totalRequiredFields, + totalFilledFields: vendor.totalFilledFields, + completionPercentage: vendor.overallCompletionPercentage + })); + + setVendorProgress(progressData); + toast.success(`${progressData.length}개 벤더의 진척도를 불러왔습니다`); } else { - toast.warning(`${testType} 결과가 없습니다`); + toast.warning('벤더 데이터가 없습니다'); } } catch (error) { - console.error(`Error in ${testType}:`, error); - toast.error(`${testType} 테스트 실패: ${error instanceof Error ? error.message : '알 수 없는 오류'}`); + console.error('Error loading vendor progress:', error); + toast.error(`벤더 진척도 로드 실패: ${error instanceof Error ? error.message : '알 수 없는 오류'}`); } finally { - setLoading(null); + setLoading(false); } }; - const renderVendorFormStats = (stats: VendorFormCompletionStats) => ( -
-
- - -
{stats.completionPercentage}%
-

완성도

-
-
- - -
{stats.totalFilledFields}
-

입력된 필드

-
-
- - -
{stats.totalRequiredFields}
-

총 필드

-
-
- - -
{stats.tagCount}
-

태그 수

-
-
-
- - - - 태그별 세부 현황 - - - -
- {stats.detailsByTag.map((tag, index) => ( -
- {tag.tagNo} -
- = 80 ? "default" : tag.completionPercentage >= 50 ? "secondary" : "destructive"}> - {tag.completionPercentage}% - - - {tag.filledFields}/{tag.requiredFields} - -
-
- ))} -
-
-
-
-
- ); - - const renderProjectSummary = (summary: ProjectVendorCompletionSummary) => ( -
-
- - -
{summary.averageCompletionPercentage}%
-

평균 완성도

-
-
- - -
{summary.totalVendors}
-

참여 벤더

-
-
- - -
{summary.projectCode}
-

프로젝트 코드

-
-
-
- - - - 벤더별 완성도 - - - -
- {summary.vendors.map((vendor, index) => ( -
- {vendor.vendorName} - = 80 ? "default" : vendor.completionPercentage >= 50 ? "secondary" : "destructive"}> - {vendor.completionPercentage}% - -
- ))} -
-
-
-
-
- ); - - const renderVendorAllContracts = (summary: VendorAllContractsCompletionSummary) => ( -
-
- - -
{summary.overallCompletionPercentage}%
-

전체 완성도

-
-
- - -
{summary.totalContracts}
-

총 계약

-
-
- - -
{summary.totalForms}
-

총 폼

-
-
- - -
{summary.totalFilledFields}/{summary.totalRequiredFields}
-

입력 필드

-
-
-
- -
- - - 프로젝트별 분석 - - - -
- {summary.projectBreakdown.map((project, index) => ( -
-
-
{project.projectName}
-
- 계약 {project.contractsCount}개, 폼 {project.formsCount}개 -
-
- = 80 ? "default" : "secondary"}> - {project.completionPercentage}% - -
- ))} -
-
-
-
- - - - 계약별 세부 현황 - - - -
- {summary.contracts.map((contract, index) => ( -
-
-
{contract.itemName}
-
- {contract.projectName} - 폼 {contract.totalForms}개 -
-
- = 80 ? "default" : "secondary"}> - {contract.averageCompletionPercentage}% - -
- ))} -
-
-
-
-
-
- ); + React.useEffect(() => { + loadVendorProgress(); + }, []); return (
-
- -

EDP Progress 서버 액션 테스트

+
+
+ +

벤더 진척도 현황

+
+
- {/* Input Parameters */} + {/* Vendor Progress List */} - - - 테스트 파라미터 - - - 아래 값들을 수정하여 다양한 시나리오를 테스트할 수 있습니다. - + 벤더별 작업 진척도 -
-
- - setContractItemId(e.target.value)} - placeholder="123" - /> + {loading ? ( +
+ + 벤더 진척도를 불러오는 중...
-
- - setFormCode(e.target.value)} - placeholder="SPR_LST" - /> + ) : vendorProgress.length === 0 ? ( +
+ 벤더 데이터가 없습니다.
+ ) : (
- - setProjectId(e.target.value)} - placeholder="1" - /> -
-
- - setVendorId(e.target.value)} - placeholder="1" - /> + {/* Header */} +
+
벤더명
+
폼 개수
+
태그 개수
+
전체 필드
+
입력 필드
+
완성도
+
+ + {/* Vendor Rows */} + +
+ {vendorProgress.map((vendor) => ( +
+
{vendor.vendorName}
+
{vendor.totalForms}
+
{vendor.tagCount}
+
{vendor.totalRequiredFields}
+
{vendor.totalFilledFields}
+
+ = 80 ? "default" : + vendor.completionPercentage >= 50 ? "secondary" : + "destructive" + } + > + {vendor.completionPercentage}% + +
+
+ ))} +
+
-
+ )} - - {/* Test Buttons */} - - - - - 테스트 액션들 - - - -
- - - - - - - - - - - -
-
-
- - - - {/* Results */} - {results && ( - - - - - 테스트 결과: {results.type} - - - - {!results.data ? ( -
- 데이터가 없습니다. 파라미터를 확인해주세요. -
- ) : results.type === 'vendor-form' ? ( - renderVendorFormStats(results.data as VendorFormCompletionStats) - ) : results.type === 'project-summary' ? ( - renderProjectSummary(results.data as ProjectVendorCompletionSummary) - ) : results.type === 'vendor-all-contracts' ? ( - renderVendorAllContracts(results.data as VendorAllContractsCompletionSummary) - ) : ( -
-
-
-                    {JSON.stringify(results.data, null, 2)}
-                  
-
-
- )} -
-
- )}
); -} +} \ No newline at end of file -- cgit v1.2.3